#define DEBUG
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

const int maxn=100, maxm=2000, maxc=100;

int sqr(int a) {
  return a*a;
}

class Side {
public:
  int u, v, c;

  static bool cmp(Side a, Side b) {
    return a.c<b.c;
  }
};

void initSet(int *f, int n) {
  for (int i=0; i<=n; i++) {
    f[i] = i;
  }
}

int getFa(int *f, int o) {
  return f[o]==o ? f[o] : f[o]=getFa(f, f[o]);
}

void merge(int *f, int u, int v) {
  int x=getFa(f, u), y=getFa(f, v);
  if (x!=y) {
    f[y] = x;
  }
}

long double solve(int o, int n, int m, Side s[], int sum, int sumq, int cnt) {
  if (cnt>n-1) {
    return 1e9;
  }
  static bool book[maxm+1];
  if (o>m) {
    static int set[maxn+1];
    initSet(set, n);
    if (cnt<n-1) {
      return 1e9;
    }
    for (int i=1; i<=m; i++) {
      if (book[i]) {
	if (getFa(set, s[i].u)!=getFa(set, s[i].v)) {
	  merge(set, s[i].u, s[i].v);
	} else {
	  return 1e9;
	}
      }
    }
    return sqrt((sumq-(long double)sqr(sum)/cnt)/cnt);
  } else {
    long double ret=1e9;
    book[o] = true;
    ret = min(ret, solve(o+1, n, m, s, sum+s[o].c, sumq+sqr(s[o].c), cnt+1));
    book[o] = false;
    ret = min(ret, solve(o+1, n, m, s, sum, sumq, cnt));
    return ret;
  }
}

int main() {
#ifdef DEBUG
  freopen("1.in", "r", stdin);
  freopen("1.out", "w", stdout);
#endif

  static Side sides[maxm+1];
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i=1; i<=m; i++) {
    scanf("%d %d %d", &sides[i].u, &sides[i].v, &sides[i].c);
  }

  if (m<=20) {
    printf("%.4LF", solve(1, n, m, sides, 0, 0, 0));
    return 0;
  }

  sort(sides+1, sides+m+1, Side::cmp);

  long double ans=1e9;
  for (int i=1; i<=m; i++) {
    int sum=0, sumq=0, suml=0, sumr=0;
    static int set[maxn+1];
    initSet(set, n);
    for (int l=i, r=i; l>0 || r<=m; ) {
      if (r>m || (l>0 && (sides[i].c-sides[l].c<sides[r].c-sides[i].c || (sides[i].c-sides[l].c==sides[r].c-sides[i].c && suml>sumr)))) {
	if (getFa(set, sides[l].u)!=getFa(set, sides[l].v)) {
	  merge(set, sides[l].u, sides[l].v);
	  sum+=sides[l].c;
	  sumq+=sqr(sides[l].c);
	  suml++;
	}
	l--;
      } else {
	if (getFa(set, sides[r].u)!=getFa(set, sides[r].v)) {
	  merge(set, sides[r].u, sides[r].v);
	  sum+=sides[r].c;
	  sumq+=sqr(sides[r].c);
	  sumr++;
	}
	r++;
      }
      if (suml+sumr==n-1) {
	break;
      }
    }

    ans = min(ans, sqrt((sumq-(long double)sqr(sum)/(n-1))/(n-1)));
  }

  printf("%.4LF", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
